{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Format DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(569, 31)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mean radius</th>\n",
       "      <th>mean texture</th>\n",
       "      <th>mean perimeter</th>\n",
       "      <th>mean area</th>\n",
       "      <th>mean smoothness</th>\n",
       "      <th>mean compactness</th>\n",
       "      <th>mean concavity</th>\n",
       "      <th>mean concave points</th>\n",
       "      <th>mean symmetry</th>\n",
       "      <th>mean fractal dimension</th>\n",
       "      <th>...</th>\n",
       "      <th>worst texture</th>\n",
       "      <th>worst perimeter</th>\n",
       "      <th>worst area</th>\n",
       "      <th>worst smoothness</th>\n",
       "      <th>worst compactness</th>\n",
       "      <th>worst concavity</th>\n",
       "      <th>worst concave points</th>\n",
       "      <th>worst symmetry</th>\n",
       "      <th>worst fractal dimension</th>\n",
       "      <th>diagnosis</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>17.99</td>\n",
       "      <td>10.38</td>\n",
       "      <td>122.80</td>\n",
       "      <td>1001.0</td>\n",
       "      <td>0.11840</td>\n",
       "      <td>0.27760</td>\n",
       "      <td>0.3001</td>\n",
       "      <td>0.14710</td>\n",
       "      <td>0.2419</td>\n",
       "      <td>0.07871</td>\n",
       "      <td>...</td>\n",
       "      <td>17.33</td>\n",
       "      <td>184.60</td>\n",
       "      <td>2019.0</td>\n",
       "      <td>0.1622</td>\n",
       "      <td>0.6656</td>\n",
       "      <td>0.7119</td>\n",
       "      <td>0.2654</td>\n",
       "      <td>0.4601</td>\n",
       "      <td>0.11890</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20.57</td>\n",
       "      <td>17.77</td>\n",
       "      <td>132.90</td>\n",
       "      <td>1326.0</td>\n",
       "      <td>0.08474</td>\n",
       "      <td>0.07864</td>\n",
       "      <td>0.0869</td>\n",
       "      <td>0.07017</td>\n",
       "      <td>0.1812</td>\n",
       "      <td>0.05667</td>\n",
       "      <td>...</td>\n",
       "      <td>23.41</td>\n",
       "      <td>158.80</td>\n",
       "      <td>1956.0</td>\n",
       "      <td>0.1238</td>\n",
       "      <td>0.1866</td>\n",
       "      <td>0.2416</td>\n",
       "      <td>0.1860</td>\n",
       "      <td>0.2750</td>\n",
       "      <td>0.08902</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>19.69</td>\n",
       "      <td>21.25</td>\n",
       "      <td>130.00</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>0.10960</td>\n",
       "      <td>0.15990</td>\n",
       "      <td>0.1974</td>\n",
       "      <td>0.12790</td>\n",
       "      <td>0.2069</td>\n",
       "      <td>0.05999</td>\n",
       "      <td>...</td>\n",
       "      <td>25.53</td>\n",
       "      <td>152.50</td>\n",
       "      <td>1709.0</td>\n",
       "      <td>0.1444</td>\n",
       "      <td>0.4245</td>\n",
       "      <td>0.4504</td>\n",
       "      <td>0.2430</td>\n",
       "      <td>0.3613</td>\n",
       "      <td>0.08758</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11.42</td>\n",
       "      <td>20.38</td>\n",
       "      <td>77.58</td>\n",
       "      <td>386.1</td>\n",
       "      <td>0.14250</td>\n",
       "      <td>0.28390</td>\n",
       "      <td>0.2414</td>\n",
       "      <td>0.10520</td>\n",
       "      <td>0.2597</td>\n",
       "      <td>0.09744</td>\n",
       "      <td>...</td>\n",
       "      <td>26.50</td>\n",
       "      <td>98.87</td>\n",
       "      <td>567.7</td>\n",
       "      <td>0.2098</td>\n",
       "      <td>0.8663</td>\n",
       "      <td>0.6869</td>\n",
       "      <td>0.2575</td>\n",
       "      <td>0.6638</td>\n",
       "      <td>0.17300</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20.29</td>\n",
       "      <td>14.34</td>\n",
       "      <td>135.10</td>\n",
       "      <td>1297.0</td>\n",
       "      <td>0.10030</td>\n",
       "      <td>0.13280</td>\n",
       "      <td>0.1980</td>\n",
       "      <td>0.10430</td>\n",
       "      <td>0.1809</td>\n",
       "      <td>0.05883</td>\n",
       "      <td>...</td>\n",
       "      <td>16.67</td>\n",
       "      <td>152.20</td>\n",
       "      <td>1575.0</td>\n",
       "      <td>0.1374</td>\n",
       "      <td>0.2050</td>\n",
       "      <td>0.4000</td>\n",
       "      <td>0.1625</td>\n",
       "      <td>0.2364</td>\n",
       "      <td>0.07678</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 31 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   mean radius  mean texture  mean perimeter  mean area  mean smoothness  \\\n",
       "0        17.99         10.38          122.80     1001.0          0.11840   \n",
       "1        20.57         17.77          132.90     1326.0          0.08474   \n",
       "2        19.69         21.25          130.00     1203.0          0.10960   \n",
       "3        11.42         20.38           77.58      386.1          0.14250   \n",
       "4        20.29         14.34          135.10     1297.0          0.10030   \n",
       "\n",
       "   mean compactness  mean concavity  mean concave points  mean symmetry  \\\n",
       "0           0.27760          0.3001              0.14710         0.2419   \n",
       "1           0.07864          0.0869              0.07017         0.1812   \n",
       "2           0.15990          0.1974              0.12790         0.2069   \n",
       "3           0.28390          0.2414              0.10520         0.2597   \n",
       "4           0.13280          0.1980              0.10430         0.1809   \n",
       "\n",
       "   mean fractal dimension    ...      worst texture  worst perimeter  \\\n",
       "0                 0.07871    ...              17.33           184.60   \n",
       "1                 0.05667    ...              23.41           158.80   \n",
       "2                 0.05999    ...              25.53           152.50   \n",
       "3                 0.09744    ...              26.50            98.87   \n",
       "4                 0.05883    ...              16.67           152.20   \n",
       "\n",
       "   worst area  worst smoothness  worst compactness  worst concavity  \\\n",
       "0      2019.0            0.1622             0.6656           0.7119   \n",
       "1      1956.0            0.1238             0.1866           0.2416   \n",
       "2      1709.0            0.1444             0.4245           0.4504   \n",
       "3       567.7            0.2098             0.8663           0.6869   \n",
       "4      1575.0            0.1374             0.2050           0.4000   \n",
       "\n",
       "   worst concave points  worst symmetry  worst fractal dimension  diagnosis  \n",
       "0                0.2654          0.4601                  0.11890          0  \n",
       "1                0.1860          0.2750                  0.08902          0  \n",
       "2                0.2430          0.3613                  0.08758          0  \n",
       "3                0.2575          0.6638                  0.17300          0  \n",
       "4                0.1625          0.2364                  0.07678          0  \n",
       "\n",
       "[5 rows x 31 columns]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "from sklearn.datasets import load_breast_cancer\n",
    "\n",
    "data = load_breast_cancer()\n",
    "train_df = pd.DataFrame(data.data, columns=data.feature_names)\n",
    "train_df[\"diagnosis\"] = data.target\n",
    "\n",
    "print(train_df.shape)\n",
    "train_df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Set Up Environment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cross-Experiment Key:   'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n"
     ]
    }
   ],
   "source": [
    "from hyperparameter_hunter import Environment, CVExperiment\n",
    "\n",
    "env = Environment(\n",
    "    train_dataset=train_df,\n",
    "    results_path=\"HyperparameterHunterAssets\",\n",
    "    target_column=\"diagnosis\",\n",
    "    metrics=[\"roc_auc_score\"],\n",
    "    cv_type=\"StratifiedKFold\",\n",
    "    cv_params=dict(n_splits=5, random_state=32),\n",
    "    verbose=1,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We're initializing our `Environment` with `verbose=1` to tell our experiments to only log the essentials because we're about to run lots of experiments.\n",
    "\n",
    "Now that HyperparameterHunter has an active `Environment`, we can do two things:\n",
    "\n",
    "# 1. Perform Experiments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:43> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:43> Initialized Experiment: 'aacc31f5-006b-4b2a-9d3c-657ab49c9842'\n",
      "<21:06:43> Hyperparameter Key:     '-lUbOmxw4PBQbJTgKXe2SQFMLkdgvTCnmTl9Wnz3CUc='\n",
      "<21:06:43> \n",
      "<21:06:43> \n",
      "<21:06:43> FINAL:    OOF(roc_auc_score=0.91671)  |  Time Elapsed: 0.04529 s\n",
      "<21:06:43> \n",
      "<21:06:43> Saving results for Experiment: 'aacc31f5-006b-4b2a-9d3c-657ab49c9842'\n"
     ]
    }
   ],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "from sklearn.svm import SVC, LinearSVC, NuSVC\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier\n",
    "from sklearn.naive_bayes import GaussianNB\n",
    "from sklearn.discriminant_analysis import LinearDiscriminantAnalysis, QuadraticDiscriminantAnalysis\n",
    "from sklearn.neural_network import MLPClassifier\n",
    "\n",
    "experiment_0 = CVExperiment(KNeighborsClassifier, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:43> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:43> Initialized Experiment: '5ca7860e-a6fb-4b72-a07d-ecaaf5e03e03'\n",
      "<21:06:43> Hyperparameter Key:     'zSm0a8Zxw7EfGD4Ai8Xz63NasLSEOwkx_bV1rNK5_W8='\n",
      "<21:06:43> \n",
      "<21:06:43> \n",
      "<21:06:43> FINAL:    OOF(roc_auc_score=0.50000)  |  Time Elapsed: 0.11869 s\n",
      "<21:06:43> \n",
      "<21:06:43> Saving results for Experiment: '5ca7860e-a6fb-4b72-a07d-ecaaf5e03e03'\n"
     ]
    }
   ],
   "source": [
    "experiment_1 = CVExperiment(SVC, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:43> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:43> Initialized Experiment: 'b07ba658-bb31-45ff-8f23-729bd550c39b'\n",
      "<21:06:43> Hyperparameter Key:     'umSzvriJIkgXYrenXLwiFwAGcPH-z8u5r8rnMRmK12Y='\n",
      "<21:06:43> \n",
      "<21:06:43> \n",
      "<21:06:43> FINAL:    OOF(roc_auc_score=0.89917)  |  Time Elapsed: 0.15589 s\n",
      "<21:06:43> \n",
      "<21:06:43> Saving results for Experiment: 'b07ba658-bb31-45ff-8f23-729bd550c39b'\n"
     ]
    }
   ],
   "source": [
    "experiment_2 = CVExperiment(LinearSVC, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:43> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:43> Initialized Experiment: '69883d40-af9b-450d-a6a4-08872690e018'\n",
      "<21:06:43> Hyperparameter Key:     'Db1ESJoQdnzn1dzxKdDO_yR4PniOYG7W6vMrybE6mxI='\n",
      "<21:06:43> \n",
      "<21:06:44> \n",
      "<21:06:44> FINAL:    OOF(roc_auc_score=0.50000)  |  Time Elapsed: 0.10987 s\n",
      "<21:06:44> \n",
      "<21:06:44> Saving results for Experiment: '69883d40-af9b-450d-a6a4-08872690e018'\n"
     ]
    }
   ],
   "source": [
    "experiment_3 = CVExperiment(NuSVC, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:44> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:44> Initialized Experiment: '98097e63-0094-4726-b9ab-90a90cb8f9a8'\n",
      "<21:06:44> Hyperparameter Key:     'Em2R2LoQaueLGw5QJS3sUe6Gpv9voIAGrND_DQmerFM='\n",
      "<21:06:44> \n",
      "<21:06:44> \n",
      "<21:06:44> FINAL:    OOF(roc_auc_score=0.92209)  |  Time Elapsed: 0.06197 s\n",
      "<21:06:44> \n",
      "<21:06:44> Saving results for Experiment: '98097e63-0094-4726-b9ab-90a90cb8f9a8'\n"
     ]
    }
   ],
   "source": [
    "experiment_4 = CVExperiment(DecisionTreeClassifier, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:44> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:44> Initialized Experiment: 'f6a00324-a7eb-438f-ad35-a1f7882641e2'\n",
      "<21:06:44> Hyperparameter Key:     'OdIHXd6SeFQi6gFbjUKsKR_KplScHEjsAppJ4Yhxpys='\n",
      "<21:06:44> \n",
      "<21:06:44> \n",
      "<21:06:44> FINAL:    OOF(roc_auc_score=0.95777)  |  Time Elapsed: 0.09257 s\n",
      "<21:06:44> \n",
      "<21:06:44> Saving results for Experiment: 'f6a00324-a7eb-438f-ad35-a1f7882641e2'\n"
     ]
    }
   ],
   "source": [
    "experiment_5 = CVExperiment(RandomForestClassifier, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:44> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:44> Initialized Experiment: '35a23c9d-311d-4e69-8e81-142218c25cfa'\n",
      "<21:06:44> Hyperparameter Key:     '65vlVQBglPtLRvLoMPQ4vo6V11XNuBPSVdGa3gfiga8='\n",
      "<21:06:44> \n",
      "<21:06:44> \n",
      "<21:06:44> FINAL:    OOF(roc_auc_score=0.96425)  |  Time Elapsed: 0.50177 s\n",
      "<21:06:44> \n",
      "<21:06:44> Saving results for Experiment: '35a23c9d-311d-4e69-8e81-142218c25cfa'\n"
     ]
    }
   ],
   "source": [
    "experiment_6 = CVExperiment(AdaBoostClassifier, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:44> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:44> Initialized Experiment: 'bd95521e-2062-479e-ac8c-07e6fe993247'\n",
      "<21:06:44> Hyperparameter Key:     'QsW5PTxiq440XcDtxUQDwRZ2k6utNZByjmD0aDq4viM='\n",
      "<21:06:44> \n",
      "<21:06:45> \n",
      "<21:06:45> FINAL:    OOF(roc_auc_score=0.95393)  |  Time Elapsed: 0.64309 s\n",
      "<21:06:45> \n",
      "<21:06:45> Saving results for Experiment: 'bd95521e-2062-479e-ac8c-07e6fe993247'\n"
     ]
    }
   ],
   "source": [
    "experiment_7 = CVExperiment(GradientBoostingClassifier, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:45> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:45> Initialized Experiment: 'c4052269-f4d4-439e-927a-d8c2f6707969'\n",
      "<21:06:45> Hyperparameter Key:     'rKKFZX71cT7Hyreg02mNi_12YKCWQWNX9X9Dm1y1mH8='\n",
      "<21:06:45> \n",
      "<21:06:45> \n",
      "<21:06:45> FINAL:    OOF(roc_auc_score=0.93035)  |  Time Elapsed: 0.03822 s\n",
      "<21:06:45> \n",
      "<21:06:45> Saving results for Experiment: 'c4052269-f4d4-439e-927a-d8c2f6707969'\n"
     ]
    }
   ],
   "source": [
    "experiment_8 = CVExperiment(GaussianNB, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:45> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:45> Initialized Experiment: 'e26e93bd-3e81-4de8-a5ca-57b4471d4376'\n",
      "<21:06:45> Hyperparameter Key:     '0oh263u3lfeNrwqq0jzCrNw1M5eMWldb8CIw6ML7qmI='\n",
      "<21:06:45> \n",
      "<21:06:45> \n",
      "<21:06:45> FINAL:    OOF(roc_auc_score=0.95003)  |  Time Elapsed: 0.04905 s\n",
      "<21:06:45> \n",
      "<21:06:45> Saving results for Experiment: 'e26e93bd-3e81-4de8-a5ca-57b4471d4376'\n"
     ]
    }
   ],
   "source": [
    "experiment_9 = CVExperiment(LinearDiscriminantAnalysis, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:45> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:45> Initialized Experiment: 'f013e207-95eb-4f72-9c20-4e587c25f52b'\n",
      "<21:06:45> Hyperparameter Key:     'qdHf2hC76V9AcGks6LKQjZoi1kM-_Z5bQBskGQ_FM5M='\n",
      "<21:06:45> \n",
      "<21:06:45> \n",
      "<21:06:45> FINAL:    OOF(roc_auc_score=0.95821)  |  Time Elapsed: 0.04468 s\n",
      "<21:06:45> \n",
      "<21:06:45> Saving results for Experiment: 'f013e207-95eb-4f72-9c20-4e587c25f52b'\n"
     ]
    }
   ],
   "source": [
    "experiment_10 = CVExperiment(QuadraticDiscriminantAnalysis, {})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<21:06:45> Validated Environment:  'aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60='\n",
      "<21:06:45> Initialized Experiment: 'b41a3b1c-ef03-47b5-82f1-00cf74b43403'\n",
      "<21:06:45> Hyperparameter Key:     'JYz6ECsGC_S2dHnO3Gxcn4-jC5odreQXXF13WwoeW_0='\n",
      "<21:06:45> \n",
      "<21:06:46> \n",
      "<21:06:46> FINAL:    OOF(roc_auc_score=0.92003)  |  Time Elapsed: 0.82798 s\n",
      "<21:06:46> \n",
      "<21:06:46> Saving results for Experiment: 'b41a3b1c-ef03-47b5-82f1-00cf74b43403'\n"
     ]
    }
   ],
   "source": [
    "experiment_11 = CVExperiment(MLPClassifier, {})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Of course, SKLearn has many more algorithms than those shown here, but I think you get the idea.\n",
    "\n",
    "Notice that in all the above experiments, we gave `CVExperiment` `model_init_params={}`. Passing an empty dict tells it to use the default hyperparameters for the `model_initializer`, which it'll figure out on its own.\n",
    "\n",
    "# 2. Hyperparameter Optimization\n",
    "\n",
    "We're just going to do optimization on one of the algorithms used above (`AdaBoostClassifier`); although, HyperparameterHunter can certainly do consecutive optimization rounds.\n",
    "\n",
    "Notice below that `optimizer` correctly identifies `experiment_6` as being the only saved experiment it can learn from because it's optimizing `AdaBoostClassifier`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Validated Environment with key: \"aZlwCukh8RVC3A3BIv1DK27sZYyUCsegMFpr2R4JB60=\"\n",
      "\u001b[31mSaved Result Files\u001b[0m\n",
      "\u001b[31m_________________________________________________________________________________________\u001b[0m\n",
      " Step |       ID |   Time |      Value |   algorithm |   learning_rate |   n_estimators | \n",
      "Experiments matching cross-experiment key/algorithm: 1\n",
      "Experiments fitting in the given space: 1\n",
      "Experiments matching current guidelines: 1\n",
      "    0 | 35a23c9d | 00m00s | \u001b[35m   0.96425\u001b[0m | \u001b[32m    SAMME.R\u001b[0m | \u001b[32m         1.0000\u001b[0m | \u001b[32m            50\u001b[0m | \n",
      "\u001b[31mHyperparameter Optimization\u001b[0m\n",
      "\u001b[31m_________________________________________________________________________________________\u001b[0m\n",
      " Step |       ID |   Time |      Value |   algorithm |   learning_rate |   n_estimators | \n",
      "    1 | 7838c551 | 00m00s |    0.96425 |     SAMME.R |          0.6864 |             68 | \n",
      "    2 | e3f8b127 | 00m00s |    0.95438 |     SAMME.R |          0.8683 |             44 | \n",
      "    3 | ec5b82e8 | 00m00s |    0.95342 |       SAMME |          0.7280 |             28 | \n",
      "    4 | e8fe7ecf | 00m00s |    0.95430 |       SAMME |          0.7983 |             36 | \n",
      "    5 | 9a5dc399 | 00m00s |    0.96425 |     SAMME.R |          0.6567 |             60 | \n",
      "    6 | c75c77fb | 00m00s | \u001b[35m   0.96565\u001b[0m | \u001b[32m    SAMME.R\u001b[0m | \u001b[32m         0.8548\u001b[0m | \u001b[32m            75\u001b[0m | \n",
      "    7 | 5b5b3b51 | 00m00s |    0.95902 |       SAMME |          0.7608 |             63 | \n",
      "    8 | d47d14cf | 00m00s |    0.95718 |     SAMME.R |          0.5465 |             54 | \n",
      "    9 | c65c2351 | 00m00s |    0.96138 |       SAMME |          0.6877 |             89 | \n",
      "   10 | d41c08b3 | 00m00s |    0.96285 |     SAMME.R |          0.8479 |             58 | \n",
      "   11 | 8801986e | 00m00s | \u001b[35m   0.97177\u001b[0m | \u001b[32m    SAMME.R\u001b[0m | \u001b[32m         0.9766\u001b[0m | \u001b[32m            56\u001b[0m | \n",
      "   12 | 3374b117 | 00m00s |    0.96617 |     SAMME.R |          0.9291 |             54 | \n",
      "Optimization loop completed in 0:00:07.677677\n",
      "Best score was 0.9717707837852122 from Experiment \"8801986e-c1f5-4c4c-8bd3-91c74be0713b\"\n"
     ]
    }
   ],
   "source": [
    "from hyperparameter_hunter import RandomForestOptPro, Real, Integer, Categorical\n",
    "\n",
    "optimizer = RandomForestOptPro(iterations=12, random_state=42)\n",
    "\n",
    "optimizer.forge_experiment(\n",
    "    model_initializer=AdaBoostClassifier,\n",
    "    model_init_params=dict(\n",
    "        n_estimators=Integer(25, 100),\n",
    "        learning_rate=Real(0.5, 1.0),\n",
    "        algorithm=Categorical([\"SAMME\", \"SAMME.R\"]),\n",
    "    ),\n",
    ")\n",
    "\n",
    "optimizer.go()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}